function fun(){
    //    console.log("a1:"+a);
        console.log("b1:"+b);
        let a = 20;
        var b = 30;
        console.log("a1:"+a);
        console.log("b1:"+b);
    }    
    fun();
//    console.log("a2:"+a);
//    console.log("b2:"+b);

    function getNum(){
        var arr = [];
        for(var i=0; i < 10; i++){
            arr[i] = function(){
                console.log(i);
            }
        }
        arr[5]();  //输出10
    }
    getNum();

    function getNum2(){
        var arr = [];
        for(var i=0; i < 10; i++){
            arr[i] = (function(i){
                return function(){
                    console.log(i);
                };
            }(i));
        }
        arr[5]();  //输出5
    }
    getNum2();
    function getNum3(){
        var arr = [];
        for(var i=0; i < 10; i++){
            arr[i] = (function(i){
                return function(){
                    console.log(i);
                }
            })(i);
        }
        arr[5]();  //输出5
    }
    getNum3();

    var a = "Hello";
    (function(){
        console.log(a);
        (function(){
            a = "world";
        })()
    })();

    var tmp = new Date();

    (function f() {
        console.log(tmp);
        if (false) {
            var tmp = 'hello world';
        }
    })()

   // f(); // undefined
